import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// 存储公共的状态
const state = {
  // 融合门户token
  CASTGC: '',
  // 教务系统token
  Edu: {
    jsessionId: '',
    sfCookie18: ''
  },
  // 学业情况数据
  academic: {}
}

// store对象
const store = new Vuex.Store({
  state,
  mutations: {
    // 用户成功登录
    handleLogin(state, val) {
      state.CASTGC = val
    },
    // 注销
    handleLogout(state) {
      state.CASTGC = '',
      state.Edu.jsessionId = '',
      state.Edu.sfCookie18 = '',
      state.academic = {}
    },
    // 成功进入教务系统
    updateEdu(state, Edu) {
      state.Edu.jsessionId = Edu.jsessionId
      state.Edu.sfCookie18 = Edu.sfCookie18
    },
    // 学业情况数据获取完成
    saveAcademic(state, academic) {
      state.academic = academic
    }
  },
  actions: {},
  getters: {}
})

export default store